home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / NDK / NDK_3.1 / Examples1 / locale / SelfLoad / getcatalogstr.asm < prev    next >
Encoding:
Assembly Source File  |  1996-02-12  |  2.0 KB  |  82 lines

  1. ;---------------------------------------------------------------------------
  2.  
  3.     NOLIST
  4.  
  5.     INCLUDE "exec/types.i"
  6.     INCLUDE "exec/lists.i"
  7.     INCLUDE "catalog.i"
  8.  
  9.     LIST
  10.  
  11. ;---------------------------------------------------------------------------
  12.  
  13.     SECTION    text,code
  14.  
  15. ;---------------------------------------------------------------------------
  16.  
  17.     XDEF    _XGetCatalogStr
  18.  
  19.     XREF    _LocaleBase
  20.     XREF    _LVOGetCatalogStr
  21. ;---------------------------------------------------------------------------
  22.  
  23.  
  24. *    string = XGetCatalogStr(catalog,stringNum,defaultString);
  25. *
  26. *    STRPTR GetCatalogStr(struct Catalog *,LONG,STRPTR);
  27. *
  28. *    arguments passed on stack
  29.  
  30. _XGetCatalogStr:
  31.     movea.l    4(sp),a0
  32.     move.l    8(sp),d0
  33.     movea.l    12(sp),a1
  34.     tst.l    _LocaleBase
  35.     beq.s    NoLocale
  36.     move.l    a6,-(sp)
  37.     movea.l    _LocaleBase,a6
  38.     jsr    _LVOGetCatalogStr(a6)
  39.     move.l    (sp)+,a6
  40.     rts
  41.  
  42. NoLocale:
  43.     move.l    a0,d1            ; set condition codes
  44.     beq.s    Default                 ; is there a catalog
  45.  
  46.     move.l  ec_Strings(a0),a0       ; pointer to string table
  47.     bra.s    EndL
  48.  
  49.     ; at this point:
  50.     ;    a0 points to string table
  51.     ;    a1 points to default string
  52.     ;    d0 contains the desired string id
  53.     ;
  54.     ; strings are stored in the table as:
  55.     ;    <4 bytes of id> <4 bytes of pointer to next string> <string>
  56.     ; the string table is terminated by a "next string" pointer equal to
  57.     ; NULL
  58.     ;
  59.     ; WARNING: there must be either no string table at all (ec_Strings
  60.     ;       equal to NULL) or the string table must contain at least
  61.     ;       one valid string. Otherwise there is no way to indicate
  62.     ;       the end of the table
  63.  
  64. Loop:    cmp.l    (a0)+,d0    ; get string id
  65.     beq.s    Success        ; if it's equal then we got what we wanted
  66.     move.l    (a0),a0        ; wasn't equal so get "next string" pointer
  67. EndL:    move.l    a0,d1        ; set condition codes
  68.     bne.s    Loop        ; if "next string" pointer is not NULL
  69.  
  70. Default:
  71.         move.l    a1,d0        ; return default string
  72.         rts
  73.  
  74. Success:
  75.     addq.l    #4,a0        ; skip over size field, given pointer to string
  76.     move.l    a0,d0        ; return pointer to string
  77.     rts            ; bye
  78.  
  79. ;---------------------------------------------------------------------------
  80.  
  81.     END
  82.